package com.cloud.applogic;

import com.cloud.pages.*;

public class NavigationHelper extends DriverBasedHelper {

    private String baseUrl;

    //Constructor
    public NavigationHelper(ApplicationManager app) {
        super(app.getWebDriver());
        this.baseUrl = app.getBaseUrl();
    }

    //Methods
    public void openRelativeUrl(String url) {
        driver.get(baseUrl + url);
    }

    public LoginPage openLoginPage() {
        if (!driver.getCurrentUrl().equals(baseUrl + "login")) {
            openRelativeUrl("login");
        }
        return new LoginPage(pages).ensurePageLoaded();
    }

    public ForgotPassPage openForgotPassPage() {
        openRelativeUrl("resetting/request");
        return new ForgotPassPage(pages).ensurePageLoaded();
    }

    public RegisterPage openRegisterPage() {
        openRelativeUrl("register");
        return new RegisterPage(pages).ensurePageLoaded();
    }

    public TermsPage openTermsPage() {
        openRelativeUrl("terms");
        return new TermsPage(pages).ensurePageLoaded();
    }

    public PrivacyPage openPrivacyPage() {
        openRelativeUrl("privacy");
        return new PrivacyPage(pages).ensurePageLoaded();
    }

}
